package com.tsingteng.cosfun.ui.message.systemnotification;

import com.tsingteng.cosfun.bean.NotificationBean;
import com.tsingteng.cosfun.bean.SystemNotificationBean;
import com.tsingteng.cosfun.callback.RxObserver;
import com.tsingteng.cosfun.mvp.presenter.BasePresenter;
/**
 * 系统通知P层
 * 常胜；
 * 2018.8.11
 * */
public class SystemNotificationPresenter extends BasePresenter implements SystemNotificationContract.INotificationPresenter {

    private SystemNotificationModel systemNotificationModel;
    SystemNotificationContract.INotificationView view;
    public SystemNotificationPresenter(){
        systemNotificationModel = new SystemNotificationModel();
    }
    @Override
    public void loginSystemNotification(String type, int page) {
        view = (SystemNotificationContract.INotificationView) getView();
        RxObserver<SystemNotificationBean> rxObserver = new RxObserver<SystemNotificationBean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {
               view.showFail(errorMsg);
            }

            @Override
            protected void onSuccess(SystemNotificationBean notificationBean) {
                view.showSystemNotificationData(notificationBean);
            }
        };
        systemNotificationModel.getUserNotification(type,page,rxObserver);
        addDisposable(rxObserver);
    }
}
